import React, { Component } from "react";
//引入路由
import { Navigate, Route, Routes } from "react-router-dom";
//引入组件
import Home from "./pages/Home";
import About from "./pages/About";
//引入一般组件   对NavLink的封装
import MyNavLint from "./component/MyNavLink";
export default class App extends Component {
  render() {
    return (
      <div>
        <div className="row">
          <div className="col-xs-offset-2 col-xs-8">
            <div className="page-header">
              <h2>React Router Demo</h2>
            </div>
          </div>
        </div>
        <div className="row">
          <div className="col-xs-2 col-xs-offset-2">
            <div className="list-group">
              {/* react路由跳转 */}
              {/* <NavLink
                activeclassname="css"
                className="list-group-item"
                to={"/home"}
              >
                Home页面
              </NavLink>
              <NavLink // activeclassname="css"
                className="list-group-item"
                to={"/about"}
              >
                About页面
              </NavLink> */}
              <MyNavLint to="/home">Home</MyNavLint>
              <MyNavLint to="/about">About</MyNavLint>
            </div>
          </div>
          <div className="col-xs-6">
            <div className="panel">
              <div className="panel-body">
                <Routes>
                  <Route path={"/home"} element={<Home />} />
                  <Route path={"/about"} element={<About />} />
                  <Route path={"/"} element={<Navigate to="/about" />} />
                </Routes>
              </div>
            </div>
          </div>
        </div>
      </div>
    );
  }
}
